﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Newsell
{
    public partial class goodList : System.Web.UI.Page
    {
        string strcid;
        List<Top.Api.Domain.Item> Sourcelist;

        protected void Page_Load(object sender, EventArgs e)
        {
            strcid = Request.QueryString["cid"];
            //strcid = Request.Form["cid"];
            if (!IsPostBack)
            {
                BindGrid(strcid, this.goodListPgr.PageSize, this.goodListPgr.CurrentPageIndex);
            }
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        private void getDate(string cid, int pagesize, int pageno)
        {
            ITopControl itopc = new ITopControl();
            if (cid == null || cid == "")
            {
                itopc.onsellsGet(Session["sessionKey"].ToString(), pagesize, pageno);
                Sourcelist = itopc.onsellres.Items;
            }
            else
            {
                itopc.onsellsGet(Session["sessionKey"].ToString(), pagesize, pageno, cid);
                Sourcelist = itopc.onsellres.Items;
            }
            goodListPgr.RecordCount = (int)itopc.onsellres.TotalResults;
        }
        /// <summary>
        /// 绑定数据源
        /// </summary>
        /// <param name="cid"></param>
        private void BindGrid(string cid, int pagesize, int pageno)
        {
            getDate(cid, pagesize, pageno);
            RepGoodList.DataSource = Sourcelist;
            RepGoodList.DataBind();
        }

        protected void RepGoodList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }

        protected void grpager_PageChanged(object sender, EventArgs e)
        {

        }
    }
}